package com.fjwt.gz.components.oss.service;

import com.alibaba.fastjson2.JSONObject;
import com.fjwt.gz.components.oss.constant.OssSavePlaceEnum;
import com.fjwt.gz.components.oss.model.OssFileConfig;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;

/**
 * OSSService 接口
 *
 * @author wg
 * @site https://pt.jdyd.xyz/
 * @date 2021/7/12 18:18
 */
public interface IOssService {

    @Data
    class UploadFormParams{

        private String formActionUrl;
        private String ossFileUrl;
        private JSONObject formParams;
    }

    /** 上传文件 & 生成下载/预览URL **/
    String upload2PreviewUrl(OssSavePlaceEnum ossSavePlaceEnum, MultipartFile multipartFile, String saveDirAndFileName);

    /** 生成上传form表单的参数 **/
    UploadFormParams genFormParams(String bizType, OssFileConfig ossFileConfig, String saveDirAndFileName);

    /** 将文件下载到本地
     * 返回是否 写入成功
     * false: 写入失败， 或者文件不存在
     * **/
    boolean downloadFile(OssSavePlaceEnum ossSavePlaceEnum, String source, String target);

}
